//
//  DashLineView.m
//  GLGW_Shoping
//
//  Created by yang on 2018/11/27.
//  Copyright © 2018年 yang. All rights reserved.
//

#import "DashLineView.h"

@implementation DashLineView{
    NSInteger line_Length;
    NSInteger line_Spacing;
    UIColor * line_Color;
    CGFloat height;
}

- (instancetype)initWithFrame:(CGRect)frame withLineLength:(NSInteger)lineLength withLineSpacing:(NSInteger)lineSpacing withLineColor:(UIColor *)lineColor{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        line_Length = lineLength;
        line_Spacing = lineSpacing;
        line_Color = lineColor;
        height = frame.size.height;
    }
    return self;
}

- (void)drawRect:(CGRect)rect {
    // Drawing code
    CGContextRef context =UIGraphicsGetCurrentContext();
    CGContextBeginPath(context);
    CGContextSetLineWidth(context,1);
    CGContextSetStrokeColorWithColor(context, line_Color.CGColor);
    CGFloat lengths[] = {line_Length,line_Spacing};
    CGContextSetLineDash(context, 0, lengths,2);
    CGContextMoveToPoint(context, 0, 0);
    CGContextAddLineToPoint(context, 0,height);
    CGContextStrokePath(context);
    CGContextClosePath(context);
}
@end
